﻿Public Class MusteriBulEkle
    Public cagiranForm As SubeEkran = Nothing


    Private Sub MusteriBulEkle_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        dgvKisiListesi.DataSource = Sorgula("select * from musteriler")
    End Sub

    Private Sub dgvKisiListesi_DoubleClick(sender As Object, e As EventArgs) Handles dgvKisiListesi.DoubleClick
        Try
            Dim seciliSatir = dgvKisiListesi.SelectedCells(0).RowIndex
            Dim tc = dgvKisiListesi.Rows(seciliSatir).Cells(0).GetEditedFormattedValue(seciliSatir, DataGridViewDataErrorContexts.Display)
            Dim ad = dgvKisiListesi.Rows(seciliSatir).Cells(1).GetEditedFormattedValue(seciliSatir, DataGridViewDataErrorContexts.Display)
            Dim soyad = dgvKisiListesi.Rows(seciliSatir).Cells(2).GetEditedFormattedValue(seciliSatir, DataGridViewDataErrorContexts.Display)
            Dim telefon = dgvKisiListesi.Rows(seciliSatir).Cells(3).GetEditedFormattedValue(seciliSatir, DataGridViewDataErrorContexts.Display)
            Dim adres = dgvKisiListesi.Rows(seciliSatir).Cells(4).GetEditedFormattedValue(seciliSatir, DataGridViewDataErrorContexts.Display)

            cagiranForm.BilgileriDoldur(tc, ad, soyad, telefon, adres)
            Me.Close()
        Catch ex As Exception
            Debug.Assert(ex.Message)
        End Try

    End Sub

    Private Sub btnEkle_Click(sender As Object, e As EventArgs) Handles btnEkle.Click
        Try
            MusteriEkle(tbTC.Text, tbAd.Text, tbSoyad.Text, tbTelefon.Text, tbAdres.Text)
            MsgBox("Müşteri Başarı ile Eklendi.", MsgBoxStyle.Information, "Başarılı")
        Catch ex As Exception
            MsgBox("Müşteri eklenemedi." & vbNewLine & ex.Message, MsgBoxStyle.Exclamation, "Başarısız")
        End Try
    End Sub


    Private Sub TabPage1_Enter(sender As Object, e As EventArgs) Handles TabPage1.Enter
        dgvKisiListesi.DataSource = Sorgula("select * from musteriler")
    End Sub
End Class